package Convert_stream_package;

import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;

public class Convert_stream_demo2 {
    public static void main(String[] args) throws IOException {
        /*
            利用转换流按照指定字符编码写出
         */

        //1、创建转换流的对象
        OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("/Users/zhaoxiaoyong/Documents/Java/" +
                "IO_stream_project/Convert_stream_module/src/rough_draft/a.txt"), "GBK");

        //2、写出数据
        osw.write("你好你好");
        //3、释放资源
        osw.close();


        FileWriter fw = new FileWriter("/Users/zhaoxiaoyong/Documents/Java/IO_stream_project/" +
                "Convert_stream_module/src/rough_draft/a.txt", Charset.forName("GBK"));
        fw.write("你好你好");
        fw.close();


    }
}
